const util = require('../utils/util.js');
const api = require('../config/api.js');

function add(data, callback) {
    util.request(api.createOrder, data, 'POST', (res) => {
        typeof callback == "function" && callback(res)
    })
}

function addById(id, callback) {
    util.request(api.createOrder + '/' + id, {}, 'POST', (res) => {
        typeof callback == "function" && callback(res)
    })
}

function get(data, callback) {
    util.request(api.getOrder, data, 'GET', (res) => {
        typeof callback == "function" && callback(res)
    })
}

function pay(data, callback) {
    util.request(api.payOrder, data, 'POST', (res) => {
        typeof callback == "function" && callback(res)
    })
}

function list(data, callback) {
    util.request(api.listOrder, data, 'GET', (res) => {
        typeof callback == "function" && callback(res)
    })
}


function del(data, callback) {
    util.request(api.delOrder, data, 'POST', (res) => {
        typeof callback == "function" && callback(res)
    })
}

function address(data, callback) {
    util.request(api.address, data, 'GET', (res) => {
        typeof callback == "function" && callback(res)
    })
}

module.exports = {
    add,
    addById,
    get,
    pay,
    list,
    del,
    address,
};
